﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:Internal="clr-namespace:Fluent.Internal"
                    xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Fluent;component\Themes\Office2010\Controls\ScrollBarWhite.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Fluent;component\Themes\Office2010\Controls\BackstageControls.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <Fluent:ObjectToImageConverter x:Key="StringToImageConvert" />
    <ControlTemplate x:Key="BackstageButtonControlTemplate"
                     TargetType="{x:Type Fluent:Button}">
        <Grid Background="#00000000">
            <Border x:Name="border"
                    BorderBrush="{x:Null}"
                    BorderThickness="0"
                    CornerRadius="1"
                    Visibility="Collapsed"
                    Background="{TemplateBinding Background}">
                <Border Margin="0"
                        CornerRadius="1"
                        BorderThickness="1"
                        BorderBrush="#19000000"
                        Background="#BFFFFFFF">
                    <Border BorderBrush="#7FFFFFFF"
                            BorderThickness="1"
                            CornerRadius="1"
                            Background="#33FFFFFF" />
                </Border>
            </Border>
            <StackPanel Orientation="Horizontal"
                        Margin="16,0,15,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center">
                <ContentPresenter x:Name="iconImage"
                                  HorizontalAlignment="Left"
                                  Height="16"
                                  VerticalAlignment="Center"
                                  Content="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToImageConvert}}"
                                  Width="16"
                                  SnapsToDevicePixels="True" />
                <TextBlock Text="{TemplateBinding Header}"
                           TextWrapping="NoWrap"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Left"
                           Margin="5,0,0,0"
                           TextTrimming="CharacterEllipsis"
                           x:Name="controlLabel" />
            </StackPanel>
        </Grid>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                    <Condition Property="IsEnabled"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="border"
                        Value="Visible" />
            </MultiTrigger>
            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter Property="Opacity"
                        TargetName="iconImage"
                        Value="0.5" />
                <Setter Property="Opacity"
                        TargetName="controlLabel"
                        Value="0.5" />
                <Setter Property="Effect"
                        TargetName="iconImage">
                    <Setter.Value>
                        <Fluent:GrayscaleEffect />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="BackstageButtonStyle"
           TargetType="{x:Type Fluent:Button}">
        <Setter Property="FocusVisualStyle"
                Value="{DynamicResource ControlStyleEmptyFocus}" />
        <Setter Property="Height"
                Value="26" />
        <Setter Property="Margin"
                Value="5,1" />
        <Setter Property="Template"
                Value="{StaticResource BackstageButtonControlTemplate}" />
        <Setter Property="Background"
                Value="{Binding Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:BackstageTabControl}}, FallbackValue=Red}" />
        <Setter Property="Foreground"
                Value="{DynamicResource BackstageFontBrush}" />
    </Style>
    <Style TargetType="{x:Type Fluent:SeparatorTabItem}"
           x:Key="BackstageSeparatorTabItemStyle">
        <Setter Property="Margin" Value="25,10,20,10"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Fluent:SeparatorTabItem}">
                    <StackPanel>
                        <TextBlock x:Name="header"
                                   Margin="10,5"
                                   TextWrapping="Wrap"
                                   Text="{TemplateBinding Header}"
                                   VerticalAlignment="Center"
                                   FontSize="14"
                                   FontWeight="SemiBold"
                                   Foreground="{DynamicResource BackstageFontBrush}"
                                   Visibility="Visible" />
                        <Line MinWidth="75" Height="2" X2="1" StrokeThickness="1.25" Stroke="White" Stretch="Uniform" Opacity="0.3"/>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasHeader"
                                 Value="False">
                            <Setter TargetName="header"
                                    Property="Visibility"
                                    Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="BackstageControlTemplate"
                     TargetType="{x:Type Fluent:BackstageTabControl}">
        <ControlTemplate.Resources>
            <ResourceDictionary>
                <Style x:Key="{x:Type Fluent:Button}"
                       TargetType="{x:Type Fluent:Button}"
                       BasedOn="{StaticResource BackstageButtonStyle}" />
                <Style x:Key="{x:Type ScrollBar}"
                       TargetType="{x:Type ScrollBar}"
                       BasedOn="{StaticResource ScrollBarWhite}" />
                <Style x:Key="{x:Type Fluent:DropDownButton}"
                       TargetType="{x:Type Fluent:DropDownButton}"
                       BasedOn="{StaticResource DropDownButtonBackstageStyle}" />
                <Style x:Key="{x:Type Fluent:ComboBox}"
                       TargetType="{x:Type Fluent:ComboBox}"
                       BasedOn="{StaticResource ComboBoxBackstageStyle}" />
                <Style x:Key="{x:Type Fluent:Spinner}"
                       TargetType="{x:Type Fluent:Spinner}"
                       BasedOn="{StaticResource SpinnerBackstageStyle}" />
                <Style TargetType="{x:Type Fluent:SeparatorTabItem}"
                       BasedOn="{StaticResource BackstageSeparatorTabItemStyle}" />
                <Storyboard x:Key="OnIsOpenTrueStoryboard">
                    <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)"
                                                      Storyboard.TargetName="grid">
                        <Fluent:EasingThicknessKeyFrame KeyTime="0"
                                                        Value="-30,0,0,0" />
                        <Fluent:EasingThicknessKeyFrame KeyTime="0:0:0.2"
                                                        Value="0">
                            <Fluent:EasingThicknessKeyFrame.EasingFunction>
                                <Fluent:CubicEase EasingMode="EaseInOut" />
                            </Fluent:EasingThicknessKeyFrame.EasingFunction>
                        </Fluent:EasingThicknessKeyFrame>
                    </ThicknessAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                   Storyboard.TargetName="grid">
                        <Fluent:EasingDoubleKeyFrame KeyTime="0"
                                                     Value="0" />
                        <Fluent:EasingDoubleKeyFrame KeyTime="0:0:0.2"
                                                     Value="1" />
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                                                   Storyboard.TargetName="backbutton">
                        <Fluent:EasingDoubleKeyFrame KeyTime="0:0:0.1"
                                                     Value="-23" />
                        <Fluent:EasingDoubleKeyFrame KeyTime="0:0:0.2"
                                                     Value="0" />
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </ResourceDictionary>
        </ControlTemplate.Resources>
        <Grid x:Name="grid"
              Margin="0"
              Background="{DynamicResource BackstageBackgroundBrush}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="115"
                                  Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid Height="Auto"
                  Grid.Column="1">
                <Grid.Resources>
                    <ResourceDictionary>
                        <Style x:Key="{x:Type Fluent:Button}"
                               TargetType="{x:Type Fluent:Button}"
                               BasedOn="{StaticResource BackstageButtonStyle}" />
                    </ResourceDictionary>
                </Grid.Resources>
                <ContentPresenter x:Name="PART_SelectedContentHost"
                                  HorizontalAlignment="Stretch"
                                  VerticalAlignment="Stretch"
                                  Height="Auto"
                                  Grid.Column="1"
                                  ContentSource="SelectedContent" />
            </Grid>
            <Grid Margin="0,-25,0,0"
                  VerticalAlignment="Stretch"
                  Background="{Binding RibbonThemeColor, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:MetroWindow}}}">
                <Grid Width="35"
                      Height="35"
                      Fluent:FrameworkHelper.UseLayoutRounding="False"
                      Margin="22,19,0,0"
                      VerticalAlignment="Top"
                      HorizontalAlignment="Left"
                      x:Name="backbutton"
                      RenderTransformOrigin="0.5,0.5">
                    <Grid.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform />
                            <SkewTransform />
                            <RotateTransform />
                            <TranslateTransform />
                        </TransformGroup>
                    </Grid.RenderTransform>
                    <Path x:Name="arrowpath"
                          Width="16"
                          Height="12"
                          Canvas.Top="10"
                          Canvas.Left="7.5"
                          Stretch="Uniform"
                          Fill="White"
                          Data="F1 M 36,22L 36,26L 19.75,26L 27,33L 20.5,33L 11,24L 20.5,15L 27,15L 19.75,22L 36,22 Z " />
                    <Ellipse x:Name="backellipse"
                             Stroke="White"
                             Height="35"
                             Canvas.Left="0"
                             Width="35"
                             StrokeThickness="2" />
                    <Path Data="M0,0 C0,35 0,35 0,35 C0,35 35,35 35,35 L35,0 z"
                          Fill="Transparent"
                          HorizontalAlignment="Stretch"
                          Margin="0"
                          Stretch="None"
                          Width="Auto" />
                    <Interactivity:Interaction.Triggers>
                        <Interactivity:EventTrigger EventName="MouseLeftButtonDown"
                                                    SourceName="backbutton">
                            <Internal:InvokeCommand Command="{x:Static Fluent:RibbonCommands.OpenBackstage}" />
                        </Interactivity:EventTrigger>
                    </Interactivity:Interaction.Triggers>
                </Grid>
                <ItemsPresenter Margin="0,69,0,0"
                                Height="Auto" />
            </Grid>
        </Grid>
        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding IsOpen, RelativeSource={RelativeSource AncestorType={x:Type Fluent:Backstage}}}"
                         Value="True">
                <DataTrigger.EnterActions>
                    <BeginStoryboard x:Name="IsOpenBeginStoryboard" Storyboard="{StaticResource OnIsOpenTrueStoryboard}" />
                </DataTrigger.EnterActions>
                <DataTrigger.ExitActions>
                    <RemoveStoryboard BeginStoryboardName="IsOpenBeginStoryboard" />
                </DataTrigger.ExitActions>
            </DataTrigger>
            <Trigger Property="IsMouseOver"
                     Value="True"
                     SourceName="backbutton">
                <Setter Property="Opacity"
                        TargetName="arrowpath"
                        Value="0.5" />
                <Setter Property="Opacity"
                        TargetName="backellipse"
                        Value="0.5" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="BackstageStyle"
           TargetType="{x:Type Fluent:BackstageTabControl}">
        <Setter Property="Foreground"
                Value="{DynamicResource DefaultFontBrush}" />
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFontFamily}" />
        <Setter Property="FontSize"
                Value="{DynamicResource DefaultFontSize}" />
        <Setter Property="Template"
                Value="{StaticResource BackstageControlTemplate}" />
        <Setter Property="FocusVisualStyle"
                Value="{DynamicResource ControlStyleEmptyFocus}" />
        <Setter Property="Margin"
                Value="0,-24,0,0" />
        <Setter Property="Background"
                Value="{Binding Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:Backstage}}, FallbackValue=Red}" />
        <Setter Property="ItemsPanelBackground"
                Value="{DynamicResource BackstagePanelBackgroundBrush}" />
    </Style>
</ResourceDictionary>